package com.yue.springDemo.business.controller;

import com.yue.springDemo.business.bean.RegisterUser;
import com.yue.springDemo.business.bean.ResponseResult;
import com.yue.springDemo.business.service.UserService;
import com.yue.springDemo.framework.expection.BusinessException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@Api(value = "注册接口", tags = {"注册接口"})
public class RegisterController {

    @Autowired
    private UserService userService;

    @ApiOperation(value = "注册用户", notes = "注册用户")
    @PostMapping("/register")
    @ResponseBody
    public ResponseResult register(@Validated RegisterUser registerUser) throws BusinessException {
        userService.register(registerUser);
        return ResponseResult.success("注册成功");
    }

    @ApiOperation(value = "重置admin", notes = "重置admin账户信息")
    @PostMapping("/resetAdmin")
    @ResponseBody
    public ResponseResult resetAdmin() {
        userService.resetAdmin();
        return ResponseResult.success("重置成功");
    }

}
